This demo of V2X-Sim dataset shows how to use nuScenes devkit to load and manipulate the database.
The complete tutorial for nuScenes devkit and nuScenes database schema can be found at https://www.nuscenes.org/nuscenes?tutorial=nuscenes.
from nuscenes.nuscenes import NuScenes
import matplotlib.pyplot as plt
import numpy as np
import os
from IPython.display import Image
import collections
in_path = '/hdd/V2X-Sim'
nusc = NuScenes(version='v1.0-mini', dataroot=in_path, verbose=True)
====== Loading NuScenes tables for version v1.0-mini... 32 category, 5 attribute, 4 visibility, 50267 instance, 18 sensor, 1350 calibrated_sensor, 135000 ego_pose, 4 log, 100 scene, 10000 sample, 135000 sample_data, 5018397 sample_annotation, 3 map, Done loading in 37.375 seconds. ====== Reverse indexing ... Done reverse indexing in 7.4 seconds. ======
The V2X-Sim dataset currently contains 100 scenes.
# To investigate a single scene
my_scene = nusc.scene[0]
my_scene
{'token': 'nq5j43bseb6vd2f1hv554ek0390tv7ui',
'log_token': 'txcvawpjz4w1il23v5seuitkgv4hw6av',
'nbr_samples': 100,
'first_sample_token': '35pny51ga4ovb6z06ejv71438g56gsnn',
'last_sample_token': 'fioe00mdk2380g3df3yxatp9kj6dgo89',
'name': 'scene_67',
'description': 'an intersection of map town5'}
There are as many as 10,000 samples in the dataset. The details for each sample can be viewed as follows.
my_scene = nusc.scene[0]
first_sample_token = my_scene['first_sample_token']
my_sample = nusc.get('sample', first_sample_token)
my_sample
{'token': '35pny51ga4ovb6z06ejv71438g56gsnn',
'timestamp': 100,
'prev': '',
'next': 'x2plwo16h4025mg3d04z7kbe4z78034p',
'scene_token': 'nq5j43bseb6vd2f1hv554ek0390tv7ui',
'data': {'CAM_FRONT_INT_id_0': '7deux7ji489sd0r048oq96u09w73zbk7',
'CAM_FRONT_INT_id_1': '5ay8cf3572z51cyhj801p8i5897r82z5',
'CAM_FRONT_INT_id_2': '1qw0uaun346756g0wv9116ya5103m8mh',
'CAM_FRONT_INT_id_3': 'wlr462np984c03s4g0eh2x9fu27opf5c',
'LIDAR_TOP_INT': 'rrss89y6wb575ef4e9021v00a58uvhun',
'BEV_TOP_INT': '1g8l957f89b6g285p32u65d5300a878m',
'BEV_RAW_TOP_INT': 'wz5svgbu6c691s88w3p2nl9y0j9930u2',
'SEMLIDAR_TOP_INT': 'lptrc1g4obv668u6kpe4bhooly370kc2',
'CAM_FRONT_id_0': 'q9dlo4x2c5y9njaef1qtg06a4i4h7476',
'CAM_BACK_id_0': '5t1998ibzx426qrlhob5id2vh67x753n',
'CAM_BACK_LEFT_id_0': '6r41ho2gygo233odtq13s5l5o3bswpr0',
'CAM_FRONT_LEFT_id_0': '57nl94af2pgjjp66zkw4s8bv371tlu9a',
'CAM_FRONT_RIGHT_id_0': 'h11832231724ui102h995532pw2go3i3',
'CAM_BACK_RIGHT_id_0': 'vqkzp65wu2qbmny255ew59580933s8k5',
'DEP_FRONT_id_0': '678wxp4h219300h07fe2ek9v28103q82',
'SEG_FRONT_id_0': 'yk31dc6k10oq3q033di7wptrxoq62xam',
'BEV_TOP_id_0': 'dn8767842934024ydrvq920162l552i1',
'BEV_RAW_TOP_id_0': '67nq43fj9cj26sn16z262u59hf1uwf4o',
'LIDAR_TOP_id_0': 'v39ar0x17cu0ss193sqp4868c51j927t',
'SEG_RAW_FRONT_id_0': '2yne2271s0tf8fzf7me482z49anxw41j',
'SEMLIDAR_TOP_id_0': '9qlpf41f29d3336541522uk15qk3zn59',
'CAM_FRONT_id_1': '8814gv7m2lzz9wvw78vzp53y8m88l40h',
'CAM_BACK_id_1': 'a5246039wxx17866y398y1ze2zxq588u',
'CAM_BACK_LEFT_id_1': 'e5q714443c74l9b8jvb20n6sg5b1156q',
'CAM_FRONT_LEFT_id_1': '06463bdy2dpy11190pso30oxxtocgt0r',
'CAM_FRONT_RIGHT_id_1': '98e49nm82m325vg8rx6jt8g40khiq1m9',
'CAM_BACK_RIGHT_id_1': 'l98b3ru676heo50c2pf1jt3c23253dhh',
'DEP_FRONT_id_1': 'z047w0u9zq29gfxho7b0m825e8167tuk',
'SEG_FRONT_id_1': '3ztf009381b6u5c3auci95iwgf38v4ic',
'BEV_TOP_id_1': '3g99n77949724ffo9p5ok776vqx5t3yd',
'BEV_RAW_TOP_id_1': 'u217f3nc8bnmrxfz797zo44f7tzwu949',
'LIDAR_TOP_id_1': 'm178l95x5032q5n39d702v4ej6krhilf',
'SEG_RAW_FRONT_id_1': 'n52j16pox56r286059670a108i2g64f2',
'SEMLIDAR_TOP_id_1': 'am1k553fz151yrrt832pm510um58949m',
'CAM_FRONT_id_2': '56ol2mpsny76iiofe4674o16zx6z8837',
'CAM_BACK_id_2': 'b6x0q7nw5lqplb3cverz3u0rnzquk2f9',
'CAM_BACK_LEFT_id_2': '9pgq03man390pb0i82363ie84bb4551a',
'CAM_FRONT_LEFT_id_2': 'z56sxa648k00i0x4hso9w29q74mm8u91',
'CAM_FRONT_RIGHT_id_2': 'k26s6z60a40p08fu57e5564s6cxhv82j',
'CAM_BACK_RIGHT_id_2': '6ks9676578rdg83bkc52uogsy6n322mn',
'DEP_FRONT_id_2': '0m8r96u02259sbe8d16ex82x9yb814i8',
'SEG_FRONT_id_2': '7920l2b2d89tyimb64f9829w0hxx8k58',
'BEV_TOP_id_2': '5u2iksx435tfale78j1if5s170wu2i68',
'BEV_RAW_TOP_id_2': '89q771744865776fgj650fb0vs7g2963',
'LIDAR_TOP_id_2': 'yp90575k04sn32ucy6me5w25k0w09a8g',
'SEG_RAW_FRONT_id_2': '9424di6151j30u7vi50239s848s0g1ii',
'SEMLIDAR_TOP_id_2': '782l188e48fcr3mbz06a90809an8235m'},
'anns': ['q14sb1xu9cn62ot0kd0mxr3ivztfs1h7',
'lj3759f64n46o2kyn7cvgocgzpbzo0h1',
'85ff4ei0l381y1be12esu41tyg0j7puc',
...,
'xuz91f8fq5oy05x4rjpg3w3xbdmq9vz7',
'960ygwy302lx8iuopl33p1942166ejt1']}
sensor_0 = 'CAM_FRONT_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_0 = 'CAM_BACK_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_0 = 'CAM_BACK_LEFT_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_0 = 'CAM_BACK_RIGHT_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_0 = 'CAM_FRONT_LEFT_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_0 = 'CAM_FRONT_RIGHT_id_0'
cam_front_data_0 = nusc.get('sample_data', my_sample['data'][sensor_0])
nusc.render_sample_data(cam_front_data_0['token'])
sensor_1 = 'CAM_FRONT_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_1 = 'CAM_BACK_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_1 = 'CAM_BACK_LEFT_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_1 = 'CAM_BACK_RIGHT_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_1 = 'CAM_FRONT_LEFT_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_1 = 'CAM_FRONT_RIGHT_id_1'
cam_front_data_1 = nusc.get('sample_data', my_sample['data'][sensor_1])
nusc.render_sample_data(cam_front_data_1['token'])
sensor_INT = 'CAM_FRONT_INT_id_0'
cam_front_data_INT = nusc.get('sample_data', my_sample['data'][sensor_INT])
nusc.render_sample_data(cam_front_data_INT['token'])
sensor_INT = 'CAM_FRONT_INT_id_1'
cam_front_data_INT = nusc.get('sample_data', my_sample['data'][sensor_INT])
nusc.render_sample_data(cam_front_data_INT['token'])
sensor_INT = 'CAM_FRONT_INT_id_2'
cam_front_data_INT = nusc.get('sample_data', my_sample['data'][sensor_INT])
nusc.render_sample_data(cam_front_data_INT['token'])
sensor_INT = 'CAM_FRONT_INT_id_3'
cam_front_data_INT = nusc.get('sample_data', my_sample['data'][sensor_INT])
nusc.render_sample_data(cam_front_data_INT['token'])
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_0', camera_channel='CAM_FRONT_id_0')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_1', camera_channel='CAM_BACK_id_0')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_1', camera_channel='CAM_FRONT_LEFT_id_1')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_1', camera_channel='CAM_FRONT_RIGHT_id_1')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_0', camera_channel='CAM_BACK_LEFT_id_0')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_id_0', camera_channel='CAM_BACK_RIGHT_id_0')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_INT', camera_channel='CAM_FRONT_INT_id_0')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_INT', camera_channel='CAM_FRONT_INT_id_1')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_INT', camera_channel='CAM_FRONT_INT_id_2')
my_sample = nusc.sample[0]
nusc.render_pointcloud_in_image(my_sample['token'], pointsensor_channel='LIDAR_TOP_INT', camera_channel='CAM_FRONT_INT_id_3')
sample_data_token = my_sample['data']['LIDAR_TOP_id_0']
nusc.render_sample_data(sample_data_token,
with_anns=True, underlay_map=False, pointsensor_channel='LIDAR_TOP_id_0', axes_limit=32)
#Image(filename='/home/ziyan/carla/PythonAPI/data_generation/~/V2X-Sim-1/sweeps/BEV_TOP_id_0/scene_1_000063.jpg', width=500, height=500)
sample_data_token = my_sample['data']['SEMLIDAR_TOP_id_1']
nusc.render_sample_data(sample_data_token,
with_anns=True, underlay_map=False, show_lidarseg=True, pointsensor_channel='SEMLIDAR_TOP_id_1', axes_limit=32)
#Image(filename='/home/ziyan/carla/PythonAPI/data_generation/~/V2X-Sim-11/sweeps/BEV_TOP_id_1/scene_11_000128.jpg', width=500, height=500)
sample_data_token = my_sample['data']['LIDAR_TOP_INT']
nusc.render_sample_data(sample_data_token,
with_anns=True, underlay_map=False, pointsensor_channel='LIDAR_TOP_INT', axes_limit=32)
#Image(filename='/home/ziyan/carla/PythonAPI/data_generation/~/V2X-Sim-2/sweeps/BEV_TOP_INT/scene_2_000063.jpg', width=500, height=500)
sample_data_token = my_sample['data']['SEMLIDAR_TOP_INT']
nusc.render_sample_data(sample_data_token,
with_anns=True, underlay_map=False, show_lidarseg=True, pointsensor_channel='SEMLIDAR_TOP_INT', axes_limit=32)
#Image(filename='/home/ziyan/carla/PythonAPI/data_generation/~/V2X-Sim-1/sweeps/BEV_TOP_INT/scene_1_000063.jpg', width=500, height=500)